package com.lagou.wwyan.blog.controller;

import com.lagou.wwyan.blog.entity.Article;
import com.lagou.wwyan.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @GetMapping
    public String index(Model model,@RequestParam(defaultValue = "0") int page,@RequestParam(defaultValue = "2") int size){
        Page<Article> rPage = articleService.getPage(page, size);
        model.addAttribute("articlePage",rPage);
        return "client/index";
    }
}
